﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Skywalker.Fluently.Tests.Fakes;

namespace Skywalker.Fluently.Tests.Factory_Tests
{
    [TestClass]
    public class execute_builder
    {
        [TestMethod]
        public void executes_the_specified_function()
        {
            // Arrange
            var factory = new Factory();
            var builder = new TestComponentBuilder();
            var expectedValue = 42;

            // Act
            factory.ExecuteBuilder(builder, x => x.SetTestProperty(expectedValue));

            // Assert
            Assert.AreEqual(expectedValue, builder.Component.TestProperty);
        }

        [TestMethod]
        public void returns_the_builder()
        {
            // Arrange
            var builder = new TestComponentBuilder();
            var factory = new Factory();

            // Act
            var returnedBuilder = factory.ExecuteBuilder(builder, x => x.SetTestProperty(42));

            // Assert
            Assert.AreSame(builder, returnedBuilder);
        }
    }
}
